/*
 * The X-Minou Projet
 * X-Minou is a text, irc like chat program for
 * local users of Unix system
 *
 * Author :  RaX| <raxxx.fr@gmail.com>
 *
 * Xminou in a free software released as-is.
 */

#include "xminou.hh"
#include "xminou_tailf.hh"

Tailf::Tailf ()
{

  m_file.open (SOCKET_FILE);

  while (!m_file.eof ())
   {
    std::string str;

    std::getline (m_file, str);
    line.push_back (str);
   }

}

const char*
Tailf::get_lastline (unsigned int n)
{

  std::string last = "";

  unsigned int i = line.size ();

  i =  (i > n) ? i - n : 0;

  for (;i < line.size (); i++)
    last += line.at (i) + "\n";

  return last.c_str ();

}

Tailf::~Tailf ()
{

  m_file.close ();

}

